<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //	写一个函数，格式化时间 formatDate(),参数可以是字符串，也可以是时间对象。效果： 2021-10-05 15：15：09 星期几
       // let year = dateObj.getFullYear(2021)
        function formatDate(a){
            let now = new Date(a);
            let year =now.getFullYear(a);
            let month = now.getMonth(a)+1;
        if(month<10){
            month="0"+getMonth(a)+1
        }
        let day1 = now.getDate(a);
        if(day1<10){
            day1 = "0"+now.getDate(a)
        }
        let hour = now.getHours(a);
        if(hour<10){
            hour = "0"+now.getHours(a)
        }
        let minutes = now.getMinutes(a);
        if(minutes<10){
            minutes = "0"+now.getMinutes(a)
        }
        let send = now.getSeconds(a);
        if(send<10){
            send = "0"+now.getSeconds(a)
        }
        let day =now.getDay(a);
        let date=year+"-"+month+"-"+day1+","+hour+":"+minutes+":"+send+"星期"+day;
        return date;
      }  
      let f = new Date();
        console.log(formatDate('2021-10-05,15:15:09'));
    </script>
</body>
</html>